home *** CD-ROM | disk | FTP | other *** search
/ La Traviata / La Traviata.iso / viewer / gifsrc.zip / READRAST.ASM < prev    next >
Assembly Source File  |  1988-02-07  |  3KB  |  78 lines

  1. ;****************************************************************************
  2. ;Written 1/28-1/29/88 by Jim Griebel.
  3. ;This Turbo object external replaces READRASTER, for a considerable gain
  4. ;in speed.
  5. ;****************************************************************************
  6.  
  7. data          segment word public
  8.               assume ds:data
  9.               extrn raster:dword,raster2:dword,gifstuff:dword
  10.               extrn nextraster:byte
  11.               extrn gifptr:word
  12.  
  13. data          ends
  14.  
  15. cseg          segment byte public
  16.               assume cs:cseg
  17.               extrn allocmem:near
  18.               extrn readmore:near
  19.  
  20.               public  readrast
  21.  
  22. ;Convert the blocked GIF data stream into an unblocked one. We can do
  23. ;this now, or do it later; doing it now saves a good deal of complication
  24. ;later on.
  25.  
  26. readrast      proc near
  27.  
  28.               push    ds
  29.               mov     ax,gifptr          ;GIFPtr points past header
  30.               les     di,raster          ;to start of blocked data.
  31.               lds     si,gifstuff        ;ES:DI points to RASTER where
  32.               add     si,ax              ;we'll put it.
  33. top:          lodsb                      ;OK. Get block size
  34.               and     al,al              ;If it's 0, we're done
  35.               jz      finis
  36.               mov     cl,al              ;Otherwise use it as loop counter
  37.               xor     ch,ch
  38. bloop:        lodsb                      ;Simple loop: GIFSTUFF>RASTER
  39.               stosb
  40.               cmp     si,64000           ;See if we overran the first
  41.               jnz     ckdi               ;RASTER array. If we did,
  42.               pop     ds
  43.               push    di
  44.               push    es
  45.               push    cx
  46.               call    readmore           ;Call a Turbo routine to get more
  47.               pop     cx                 ;from the GIF file
  48.               pop     es
  49.               pop     di
  50.               push    ds                 ;And repoint to the start of
  51.               lds     si,gifstuff        ;GIFSTUFF
  52. ckdi:         cmp     di,64000           ;See if we ran out of RASTER
  53.               jnz     proceed            ;Nope
  54.               mov     ax,ds              ;If we did, get address of
  55.               pop     ds                 ;RASTER2's pointer
  56.               lea     di,raster2
  57.               inc     byte ptr nextraster
  58.               push    ax                 ;Push sensitive regs
  59.               push    cx
  60.               push    si
  61.               push    ds                 ;And the variable for Turbo
  62.               push    di
  63.               call    allocmem           ;Go get memory for RASTER2
  64.               pop     si
  65.               pop     cx
  66.               pop     ax
  67.               push    ds
  68.               les     di,raster2         ;Repoint DI to actual array
  69.               mov     ds,ax
  70. proceed:      loop    bloop              ;And continue until done.
  71.               jmp     top
  72. finis:        pop     ds
  73.               ret
  74.  
  75. readrast      endp
  76.               cseg ends
  77.               end  readrast
  78.               end